﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfApplication2.ViewModels.Afiliado;
using WpfApplication2.Helpers;
using WpfApplication2.UserControls;
using WpfApplication2.Validation;
using System.Globalization;

using WpfApplication2.ViewModels.Nomenclador;

namespace WpfApplication2.Views.Nomenclador
{
    /// <summary>
    /// Interaction logic for ConsultarNomenclador.xaml
    /// </summary>
    public partial class ConsultarNomenclador : Page
    {
        public Instancias Instancias { get; set; }
        public ConsultarNomenclador(Instancias instancias)
        {
            InitializeComponent();
            DataContext = new ConsultarNomencladorViewModel(instancias);
            Instancias = instancias;
        }

        private void textbox_TextChanged(object sender, TextChangedEventArgs e)
        {
            EnableDisableButtons(sender as TextBox);
        }
        private void EnableDisableButtons(TextBox tb)
        {
            Image img = (tb.Parent as StackPanel).Children[1] as Image;
            if (string.IsNullOrEmpty(tb.Text))
                img.Source = new BitmapImage(new Uri("../../Images/delete_btn.png", UriKind.Relative));
            else
                img.Source = new BitmapImage(new Uri("../../Images/delete_btn_hover.png", UriKind.Relative));
        }
        private void BtnLimpiar_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Image img = sender as Image;
            TextBox tb = (img.Parent as StackPanel).Children[0] as TextBox;
            if (tb.Text.Length > 0)
            {
                img.Source = new BitmapImage(new Uri("../../Images/delete_btn.png", UriKind.Relative));
                tb.Text = string.Empty;
            }
        }
    }
}
